package fr.cpe.dp.projet2.view;

import fr.cpe.dp.projet2.model.algo.IAlgorithm;
import fr.cpe.dp.projet2.model.shape.IShape;
import java.awt.Graphics;
import javax.swing.JPanel;

/**
 *
 * @author Benoit
 */
public class DrawPanelView extends JPanel {
    private IAlgorithm choosenAlgorithm;
    private IShape choosenShape;
    private Boolean isDrawAllowed;

    public DrawPanelView() {
        choosenAlgorithm = null;
        choosenShape = null;
        isDrawAllowed = false;
    }
    
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        
        if(isDrawAllowed) {
            choosenShape.draw(g, choosenAlgorithm);
            isDrawAllowed = false;
        }
    }
    
    public void setChoosenAlgorithm(IAlgorithm choosenAlgorithm) {
        this.choosenAlgorithm = choosenAlgorithm;
    }

    public void setChoosenShape(IShape choosenShape) {
        this.choosenShape = choosenShape;
    }

    public void setIsDrawAllowed(Boolean isDrawAllowed) {
        this.isDrawAllowed = isDrawAllowed;
    }
}
